<template>
  <div>
    <datatable :table-fomat="tableFomat" :table-data="tableData">
      <el-table-column prop="name" label="是否启用" width="120">
        <template slot-scope="scope">
          <el-switch
            v-model="switchs[scope.$index]"
            active-color="#13ce66"
            inactive-color="#ff4949"
          />
        </template>
      </el-table-column>
    </datatable>
  </div>
</template>
<script>
import datatable from '@/views/my-views/components/table'
import goods from '@/sql/table-field'
export default {
  components: {
    datatable
  },
  data() {
    return {
      switchs: [],
      tableFomat: goods.goods_type,
      tableData: []
    }
  },
  mounted() {
    // console.log('index-token',this.$store.state.goods.access_token)
    this.$store.dispatch('getGoodsTypes').then(res => {
      this.tableData = res.data
      console.log(res.data)
    }).catch(err => {
      if (err.errcode == 40001) {
        alert('token失效 请重新登录')
      } else {
        console.log('获取GoodsTypes失', err)
      }
    })
  },
  methods: {

  }
}
</script>
